﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace Spotless.Data
{
    [MetadataType(typeof(Customer_Metadata))]
    public partial class Customer
    {
        //public enum QueryTypes : byte
        //{
        //    Enquiry = 2,
        //    Complaint = 3
        //}

        //public enum QuerySource : byte
        //{
        //    Website = 1,
        //    Email = 2,
        //    Telephone = 3,
        //    Letter = 4
        //}

        //public enum QueryStatus : byte
        //{
        //    Not_Started = 1,
        //    In_Progress = 2,
        //    Complete = 3
        //}

        public enum Methods : byte
        {
            DDM = 1,
            Web = 2,
            Email = 3
        }

        //public QueryTypes? QueryType
        //{
        //    get
        //    {
        //        if (this.QueryTypeId.HasValue)
        //            return (QueryTypes)this.QueryTypeId;
        //        else
        //            return null;
        //    }
        //    set
        //    {
        //        if (value.HasValue)
        //            this._QueryTypeId = (byte)value;
        //        else
        //            this._QueryTypeId = null;

        //    }
        //}

        //public QuerySource Source
        //{
        //    get
        //    {
        //        return (QuerySource)this.SourceId;
        //    }
        //    set
        //    {
        //        this._SourceId = (byte)value;
        //    }
        //}

        //public QueryStatus Status
        //{
        //    get
        //    {
        //        return (QueryStatus)this.StatusId;
        //    }
        //    set
        //    {
        //        this._StatusId = (byte)value;
        //    }
        //}

        public Methods? Method
        {
            get
            {
                if (this.MethodId.HasValue)
                    return (Methods)this.MethodId;
                else
                    return null;
            }
            set
            {
                if (value.HasValue)
                    this._MethodId = (byte)value;
                else
                    this._MethodId = null;
            }
        }

        partial void OnValidate(System.Data.Linq.ChangeAction action)
        {
            if (action == System.Data.Linq.ChangeAction.Insert)
                this._Created = this._Updated = DateTime.Now;
            else if(action == System.Data.Linq.ChangeAction.Update)
                this._Updated = DateTime.Now;
        }


        public string DisplayName
        {
            get
            {
                return (this.FirstName + " " + this.LastName).Trim();
            }
        }
    }

    public class Customer_Metadata
    {
        //[DisplayName("Id")]
        public int CustomerId{ get; set; }

        [DisplayName("Title")]
        public string Title { get; set; }
        
        [Required]
        [DisplayName("First Name")]
        public string FirstName { get; set; }
        
        [Required]
        [DisplayName("Last Name")]
        public string LastName { get; set; }

        [DisplayName("Email")]
        public string Email { get; set; }

        [DisplayName("Phone Mobile")]
        public string PhoneMobile { get; set; }
        
        [DisplayName("Phone Landline")]
        public string PhoneLandline { get; set; }
       
        [DisplayName("Address 1")]
        public string AddressLine1 { get; set; }

        [DisplayName("Address 2")]
        public string AddressLine2 { get; set; }

        [DisplayName("Town")]
        public string Town { get; set; }

        [DisplayName("County")]
        public string County { get; set; }

        [DisplayName("Post Code")]
        public string PostCode { get; set; }

        [DisplayName("Country")]
        public string Country { get; set; }

        [DisplayName("Last Contact Date")]
        public string LastContactDate { get; set; }

        [DisplayName("Date Of Birth")]
        public string DateOfBirth { get; set; }

        //[DisplayName("Source")]
        //public string Source { get; set; }

        [DisplayName("Method")]
        public string Method { get; set; }

        //[Required]
        [DisplayName("Sample Request")]
        public bool SampleRequest { get; set; }

        //[Required]
        [DisplayName("Sample Sent")]
        public bool SampleSent { get; set; }

        
        [Required(ErrorMessage = "{0} is required")]
        [DisplayName("Category")]
        public int CategoryId { get; set; }

        [DisplayName("Product")]
        [Range(1, 1000000, ErrorMessage = "{0} is required")]
        [Required(ErrorMessage = "{0} is required")]
        public int ProductId { get; set; }

        //
        //
        //
        //Created
        //Updated
    
    }
}
